package graphquerying.reachability;

/**
 * Used for labeling R-nodes in RandomedLabeling algorithm
 * @author BaiJian
 */
public class Interval {
	
	public static final int START_RANK = 1;
	
	private int selfRank = START_RANK;
	private int lowestRank = START_RANK;
	
	public int getSelfRank() {
		return selfRank;
	}
	public void setSelfRank(int selfRank) {
		this.selfRank = selfRank;
	}
	public int getLowestRank() {
		return lowestRank;
	}
	public void setLowestRank(int lowestRank) {
		this.lowestRank = lowestRank;
	}
	
	public String toString() {
		return "[" + lowestRank + "," + selfRank + "]";
	}
	
	/**
	 * Check whether this interval is contained by another interval
	 * @param superInterval The super interval to be tested
	 * 
	 * @return <code>true</code> if <b>this</b> is contained by the <b>superInterval</b>.Otherwise <code>false</code>
	 */
	public boolean isContainedBy(Interval superInterval) {
		return lowestRank >= superInterval.getLowestRank() && selfRank <= superInterval.getSelfRank();
	}
}
